
import {Sprite} from "../base/Sprite.js";
import {Director} from "../Director.js";
const screenWidth    = window.innerWidth

export class FoodsB extends Sprite {
    constructor(radX,radY) {
        const image = Sprite.getImage('background');
        if(radX-40<0){
            radX=0
        }else if(radX+40>screenWidth){
            radX=screenWidth-60
        }
        super(image,
            0, 0,
            image.width, image.height,
            radX, -radY,
            40,40);
            this.dropSpeed = Director.getInstance().moveSpeed
            this.score=8
    }
    draw(){
        this.y = this.y + this.dropSpeed;

        // if (this.y > (screenHeight)) {
        //     this.y = -Math.random()*100;
        //     this.x=Math.random()*screenWidth;
        // }
        super.draw(this.image,
            this.srcX,
            this.srcY,
            this.srcW,
            this.srcH,
            this.x,
            this.y,
            this.width,
            this.height)
    }
}